//package com.gitlab.lucky.common.security.service;
//
//import cn.hutool.core.bean.BeanUtil;
//import com.gitlab.lucky.common.dao.model.PlatformData;
//import com.gitlab.lucky.common.security.config.JwtUser;
//import com.gitlab.lucky.common.service.PlatformDataService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.core.GrantedAuthority;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.stereotype.Service;
//
//import java.util.Collection;
//
///**
// * @author jie
// * @date 2018-11-22
// */
//@Service
//public class JwtUserDetailsService implements UserDetailsService {
//
//    @Autowired
//    private PlatformDataService platformDataService;
//
//    @Autowired
//    private JwtPermissionService permissionService;
//
//    @Override
//    public UserDetails loadUserByUsername(String username){
//        PlatformData platformData = platformDataService.selectByAppId(username);
//        if (platformData == null) {
//            return null;
//        }
//        JwtUser jwtUser = new JwtUser();
//        jwtUser.setId(platformData.getId());
//        jwtUser.setAppId(platformData.getAppId());
//        jwtUser.setAppSceart(platformData.getAppSceart());
//        Collection<GrantedAuthority> grantedAuthorities = permissionService.mapToGrantedAuthorities(jwtUser);
//        jwtUser.setAuthorities(grantedAuthorities);
//        return jwtUser;
//    }
//}
